package com.activity;

import muslim.toolkit.R;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.KeyEvent;
import android.view.Window;
import android.view.WindowManager;

import com.commun.Param;
import com.google.android.maps.MapActivity;

public class HomeStartUpActivity extends MapActivity {

	/** Called when the activity is first created. */
	public boolean isBackPressed = false;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setFullscreen();
		setContentView(R.layout.home);

	}

	public void setFullscreen() {
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);
	}

	@Override
	protected void onResume() {
		super.onResume();
		new Handler().postDelayed(new Runnable() {
			public void run() {
				if (!isBackPressed) {

					final Intent mainIntent = new Intent(
							HomeStartUpActivity.this,
							MyApplicationMainActivity.class);
					startActivityForResult(mainIntent, 1);
					finish();
				}
			}
		}, Param.TIME_IN_SECONDE_OF_HOME_ACTIVITY * 1000);
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			finish();
			isBackPressed = true;

			return true;
		}
		return super.onKeyDown(keyCode, event);
	}

	@Override
	protected boolean isRouteDisplayed() {
		return false;
	}

}
